package cn.jolyoulu.adminweb.entity.vo;

import lombok.Data;
import lombok.experimental.Accessors;
import cn.jolyoulu.cmnservice.entity.po.SysUser;

import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * @Author LuZhouJin
 * @Date 2023/3/15
 */
@Data
@Accessors(chain = true)
public class SysUserInfoVO {

    /**
     * 用户id
     */
    private String id;

    /**
     * 登录账号
     */
    private String account;


    /**
     * 电子邮箱
     */
    private String email;


    /**
     * 头像路径
     */
    private String headimgUrl;


    /**
     * 用户昵称
     */
    private String nickname;

    /**
     * 手机号码
     */
    private String phone;

    /**
     * 用户性别
     */
    private Integer sex;

    /**
     * 权限列表
     */
    private Set<String> permissions;

    /**
     * 角色列表
     */
    private List<SysRoleVO> roles;

    public SysUserInfoVO(SysUser sysUser, Set<String> permissions, List<SysRoleVO> roles) {
        if (Objects.nonNull(sysUser)) {
            this.id = sysUser.getId();
            this.account = sysUser.getAccount();
            this.email = sysUser.getEmail();
            this.headimgUrl = sysUser.getHeadimgUrl();
            this.nickname = sysUser.getNickname();
            this.phone = sysUser.getPhone();
            this.sex = sysUser.getSex();
            this.permissions = permissions;
            this.roles = roles;
        }
    }
}
